<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #chatBox{
            width: 200px;
            height: 200px;
           border: 1px solid palevioletred;
           
        }
    </style>
</head>
<body>
    <div id="chatBox"></div>
    <input type="text" id="txt">
    <input type="button" value="发送" id="btnSend">
    <br>
    <input type="radio" name="speedKey" checked>enter 发送
    <input type="radio" name="speedKey" >enter+Ctrl 发送
    <script>
        btnSend.onclik=function(){
            send();
        }
        document.onkeydown=function(event){
            var e=event||window.event;
             var speedkeys=document.getElementsByName("speedKey");
             if(speedkeys[0].checked){
                if(e.ctrlKey==false&&e.altKey==false&&e.shiftKey==false&&e.keyCode==13){
                send();
        
            }
        }else{
                if(e.ctrlKey==true&&e.keyCode==13){
                    send()
                }
            }
             }
        
        function send(){
            var str=document.getElementById("txt").value;
            chatBox.innerHTML += str+"<br/>";
            document.getElementById("txt").value="";
            documne.getElementById("txt").focus()
        }
    </script>
</body>
</html>